﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace Team4sCMDB
{
    public class UserClass : Model
    {
        public UserClass(string pathToDatabase):base(pathToDatabase)
        {
            
        }

        // Get a list of users
        public List<User> getUser()
        {
            DataTable result = executeSelectStatement("SELECT * FROM gebruiker;");
            List<User> l = new List<User>();

            foreach (DataRow row in result.Rows)
            {
                User s = new User(Convert.ToInt32(row["gebruikerID"]), Convert.ToInt32(row["CInr"]), row["gebruikersnaam"].ToString(), Convert.ToInt32(row["gebruikersgroepID"]), Convert.ToInt32(row["PCid"]));
                l.Add(s);
            }
            return l;
        }

        
        // Get single selected user to show in panel
        public DataTable getSelectedUser(string id) 
        {
            string sql = "SELECT * FROM gebruiker WHERE gebruikerID = '"+id+"'";

            DataTable res = executeSelectStatement(sql);
            return res;
        }

    }
}
